package com.hwadee.teachingprocessmanagementsystem.util;

import org.apache.commons.codec.binary.Base64;

import java.security.MessageDigest;
import java.util.Arrays;

/**
 * @Description: MD5加密工具类
 */
public class MD5Utils {
	private static ColorLoggerUtils logger = ColorLoggerUtils.getLogger(MD5Utils.class);

	public static String getMD5Str(String strValue) throws Exception {
		MessageDigest md5 = MessageDigest.getInstance("MD5");
        return Base64.encodeBase64String(md5.digest(strValue.getBytes()));
	}

	public static void main(String[] args) {
		try {
			String md5 = getMD5Str("123456");
			System.out.println(md5);
		} catch (Exception e) {
			logger.error(e.getMessage()+ Arrays.toString(e.getStackTrace()));
		}
	}
}
